import 'package:flutter/material.dart';
import 'package:flutterapp/chapter/eight/event_8_2_gesture.dart';
import 'package:flutterapp/utils/navigator_utils.dart';

import 'event_8_1_listener.dart';
import 'event_8_3_event_bus.dart';
import 'event_8_4_notification.dart';

/// @date 2020/08/05  17:38
/// @author 程志强
/// @des 事件处理与通知

class EightMain extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("事件处理与通知"),
      ),
      body: Container(
        margin: const EdgeInsets.symmetric(horizontal: 20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: _list(context),
        ),
      ),
    );
  }

  List<Widget> _list(BuildContext context) => [
        RaisedButton(
            child: Text("原始指针事件处理:Listener"),
            onPressed: () =>
                NavigatorUtil.goPageByPush(context, EventListenerRoute())),
        RaisedButton(
            child: Text("手势识别"),
            onPressed: () =>
                NavigatorUtil.goPageByPush(context, GestureDetectorRoute())),
        RaisedButton(
            child: Text("事件总线"),
            onPressed: () =>
                NavigatorUtil.goPageByPush(context, EventBusRoute())),
        RaisedButton(
            child: Text("Notification"),
            onPressed: () =>
                NavigatorUtil.goPageByPush(context, NotificationRoute())),
      ];
}
